Side navigation
Ticket #3127: hover-mike[5762].diff
File hover-mike[5762].diff, 2.4 KB (added by flesler, July 03, 2008 10:30PM UTC)
Mike's proposal (378 bytes)
Index: jquery/src/event.js
===================================================================
--- jquery/src/event.js (revision 5762)
+++ jquery/src/event.js (working copy)
@@ -363,58 +363,29 @@
setup: function() {
// Make sure the ready event is setup
bindReady();
- return;
},
- teardown: function() { return; }
- },
-
- mouseenter: {
- setup: function() {
- if ( jQuery.browser.msie ) return false;
- jQuery(this).bind("mouseover", jQuery.event.special.mouseenter.handler);
- return true;
- },
-
- teardown: function() {
- if ( jQuery.browser.msie ) return false;
- jQuery(this).unbind("mouseover", jQuery.event.special.mouseenter.handler);
- return true;
- },
-
- handler: function(event) {
- // If we actually just moused on to a sub-element, ignore it
- if ( withinElement(event, this) ) return true;
- // Execute the right handlers by setting the event type to mouseenter
- event.type = "mouseenter";
- return jQuery.event.handle.apply(this, arguments);
- }
- },
-
- mouseleave: {
- setup: function() {
- if ( jQuery.browser.msie ) return false;
- jQuery(this).bind("mouseout", jQuery.event.special.mouseleave.handler);
- return true;
- },
-
- teardown: function() {
- if ( jQuery.browser.msie ) return false;
- jQuery(this).unbind("mouseout", jQuery.event.special.mouseleave.handler);
- return true;
- },
-
- handler: function(event) {
- // If we actually just moused on to a sub-element, ignore it
- if ( withinElement(event, this) ) return true;
- // Execute the right handlers by setting the event type to mouseleave
- event.type = "mouseleave";
- return jQuery.event.handle.apply(this, arguments);
- }
+ teardown: function() { }
}
}
};
+jQuery.each({ mouseover: 'mouseenter', mouseout: 'mouseleave' }, function( orig, fix ){
+ var ev = jQuery.event.special[ fix ] = {
+ setup: function(){
+ return jQuery.browser.msie ? false : jQuery( this ).bind( orig, ev.handler );
+ },
+ teardown: function(){
+ return jQuery.browser.msie ? false : jQuery( this ).unbind( orig, ev.handler );
+ },
+ handler: function( event ){
+ event.type = fix;
+ return withinElement( event, this ) || jQuery.event.handle.apply( this, arguments );
+ }
+ };
+});
+
+
jQuery.fn.extend({
bind: function( type, data, fn ) {
return type == "unload" ? this.one(type, data, fn) : this.each(function(){
Download in other formats:
Original Format
File hover-mike[5762].diff, 2.4 KB (added by flesler, July 03, 2008 10:30PM UTC)
Mike's proposal (378 bytes)
Index: jquery/src/event.js
===================================================================
--- jquery/src/event.js (revision 5762)
+++ jquery/src/event.js (working copy)
@@ -363,58 +363,29 @@
setup: function() {
// Make sure the ready event is setup
bindReady();
- return;
},
- teardown: function() { return; }
- },
-
- mouseenter: {
- setup: function() {
- if ( jQuery.browser.msie ) return false;
- jQuery(this).bind("mouseover", jQuery.event.special.mouseenter.handler);
- return true;
- },
-
- teardown: function() {
- if ( jQuery.browser.msie ) return false;
- jQuery(this).unbind("mouseover", jQuery.event.special.mouseenter.handler);
- return true;
- },
-
- handler: function(event) {
- // If we actually just moused on to a sub-element, ignore it
- if ( withinElement(event, this) ) return true;
- // Execute the right handlers by setting the event type to mouseenter
- event.type = "mouseenter";
- return jQuery.event.handle.apply(this, arguments);
- }
- },
-
- mouseleave: {
- setup: function() {
- if ( jQuery.browser.msie ) return false;
- jQuery(this).bind("mouseout", jQuery.event.special.mouseleave.handler);
- return true;
- },
-
- teardown: function() {
- if ( jQuery.browser.msie ) return false;
- jQuery(this).unbind("mouseout", jQuery.event.special.mouseleave.handler);
- return true;
- },
-
- handler: function(event) {
- // If we actually just moused on to a sub-element, ignore it
- if ( withinElement(event, this) ) return true;
- // Execute the right handlers by setting the event type to mouseleave
- event.type = "mouseleave";
- return jQuery.event.handle.apply(this, arguments);
- }
+ teardown: function() { }
}
}
};
+jQuery.each({ mouseover: 'mouseenter', mouseout: 'mouseleave' }, function( orig, fix ){
+ var ev = jQuery.event.special[ fix ] = {
+ setup: function(){
+ return jQuery.browser.msie ? false : jQuery( this ).bind( orig, ev.handler );
+ },
+ teardown: function(){
+ return jQuery.browser.msie ? false : jQuery( this ).unbind( orig, ev.handler );
+ },
+ handler: function( event ){
+ event.type = fix;
+ return withinElement( event, this ) || jQuery.event.handle.apply( this, arguments );
+ }
+ };
+});
+
+
jQuery.fn.extend({
bind: function( type, data, fn ) {
return type == "unload" ? this.one(type, data, fn) : this.each(function(){